#pragma once
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <strsafe.h>
class Util
{
public:
	Util(void);
	~Util(void);
	static void log(char* message)
	{
		 HANDLE hFile; 
		DWORD dwBytesToWrite = (DWORD)strlen(message);
		DWORD dwBytesWritten = 0;
		BOOL bErrorFlag = FALSE;

		

		hFile = CreateFile(_T("C:\\LogonUI.txt"),                // name of the write
						   GENERIC_WRITE,          // open for writing
						   0,                      // do not share
						   NULL,                   // default security
						   OPEN_ALWAYS,             // create new file only
						   FILE_ATTRIBUTE_NORMAL,  // normal file
						   NULL);                  // no attr. template

		if (hFile == INVALID_HANDLE_VALUE) 
		{ 
			//DisplayError(TEXT("CreateFile"));
			//_tprintf(TEXT("Terminal failure: Unable to open file \"%s\" for write.\n"), argv[1]);
			return;
		}

		//_tprintf(TEXT("Writing %d bytes to %s.\n"), dwBytesToWrite, argv[1]);

		bErrorFlag = WriteFile( 
						hFile,           // open file handle
						message,      // start of data to write
						dwBytesToWrite,  // number of bytes to write
						&dwBytesWritten, // number of bytes that were written
						NULL);            // no overlapped structure

		if (FALSE == bErrorFlag)
		{
			//DisplayError(TEXT("WriteFile"));
			//printf("Terminal failure: Unable to write to file.\n");
		}
		else
		{
			if (dwBytesWritten != dwBytesToWrite)
			{
				// This is an error because a synchronous write that results in
				// success (WriteFile returns TRUE) should write all data as
				// requested. This would not necessarily be the case for
				// asynchronous writes.
				//printf("Error: dwBytesWritten != dwBytesToWrite\n");
			}
			else
			{
				//_tprintf(TEXT("Wrote %d bytes to %s successfully.\n"), dwBytesWritten, argv[1]);
			}
		}

		CloseHandle(hFile);	
	}
};
